
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
      function formatExcelDate(numb, format = '/') {
        const time = new Date((numb - 25567) * 24 * 3600000 - 5 * 60 * 1000 - 43 * 1000 - 24 * 3600000 - 8 * 3600000)
        time.setYear(time.getFullYear())
        const year = time.getFullYear() + ''
        const month = time.getMonth() + 1 + ''
        const date = time.getDate() + ''
        if (format && format.length === 1) {
          return year + format + month + format + date
        }
        return year + (month < 10 ? '0' + month : month) + (date < 10 ? '0' + date : date)
      }
     
      function transZhkeyToEnkey() {
        // 1. 映射对象，根据映射对象找英文的键
        const mapInfo = {
                '入职日期': 'timeOfEntry',
                '手机号': 'mobile',
                '姓名': 'username',
                '转正日期': 'correctionTime',
                '工号': 'workNumber',
                '部门': 'departmentName',
                '聘用形式': 'formOfEmployment'
            }
            // 2. 遍历数组取出一个个的对象，获取到中文的key
            return data.map(item => {
              const enObj = {}
              Object.keys(item).forEach(zhKey => {
                const enkey = mapInfo[zhKey]
                if(enkey === 'timeOfEntry' || enkey ==="correctionTime") {
                  enObj[enkey] = new Date(formatExcelDate(item[zhKey]))
                } else {
                  enObj[enkey] = item[zhKey]
                }
              })
              return enObj
            })
          }

      

        
        // function dataFormat(data) {
            // 将data中的数据的key按照改为指定的英文 

            

        //     const result = data.map(zhObj => {
        //         const enObj = {}
        //         const zhkeys = Object.keys(zhObj) // ['入职日期', '姓名', '工号', '手机号', '转正日期', '部门']
        //         zhkeys.forEach(zhkey => {
            
        //             const enkey = mapInfo[zhkey]
        //             enObj[enkey] = zhObj[zhkey]
                    
        //         })

        //         return enObj
        //     })

        //     return result
        // }

        // const result = dataFormat(data)
        // console.log(result);



    </script>
</head>

<body>

</body>

</html>